function Clone() {
}
function clone(obj) {
	Clone.prototype = obj;
	return new Clone();
}
function isInt(x) {
	var y = parseInt(x);
	if (isNaN(y))
		return false;
	return x == y && x.toString() == y.toString();
}

jQuery(document).ready(function() {

	// meniu
		jQuery("ul.sf-menu").supersubs( {
			minWidth : 10,
			maxWidth : 30,
			extraWidth : 1
		}).superfish( {
			delay : 100,
			speed : "fast"
		});
		jQuery("ul.sf-menu > li > a").css( {
			"color" : "white",
			"font-size" : "16px",
			"font-weight" : "bold",
			"text-shadow" : "black 0px 0px 30px"
		});

		// formuri #content
		cf = {
			all : jQuery("#content form"),
			rows : jQuery("#content form>ul>li"),
			errors : jQuery("#content form ul.error_list"),
			labels : jQuery("#content form label"),
			controls : jQuery("#content form label").next()
		};
		cf.errors.parent("li").addClass("error_row");
		cf.rows.click(function() {
			if ($("label", this).siblings().size() < 2)
				$("label", this).next().focus();
		});
		cf.errors.click(function() {
			$(this).siblings("label").next().select();
		});
		cf.errors.each(function() {
			$(this).parents("form").addClass("has_errors");
			if (!$(this).siblings().size())
				$(this).parent().addClass("global");
		});

		// date inputs
		$.datepicker.setDefaults($.extend( {
			showMonthAfterYear : false
		}, $.datepicker.regional['ro']));
		jQuery("input.data")
				.datepicker(
						{
							showButtonPanel : true,
							dateFormat : 'yy-mm-dd',
							currentText : 'azi',
							dayNames : [ 'duminica', 'luni', 'marti',
									'miercuri', 'joi', 'vineri', 'sambata' ],
							monthNames : [ 'Ianuarie', 'Februarie', 'Martie',
									'Aprilie', 'Mai', 'Iunie', 'Iulie',
									'August', 'Septembrie', 'Octombrie',
									'Noiembrie', 'Decembrie' ],
							firstDay : 1,
							maxDate : '+2y +1m',
							minDate : '-1y',
							nextText : 'inainte',
							prevText : 'inchide',
							closeText : 'gata',
							numberOfMonths : 1
						});
		jQuery('a.ajax').ajaxifyLink();
	});

jQuery.fn.hoverClass = function(c) {
	return this.each(function() {
		jQuery(this).hover(function() {
			jQuery(this).addClass(c);
		}, function() {
			jQuery(this).removeClass(c);
		});
	});
};

jQuery.fn.ajaxifyLink = function(options) {
	var linkHash = jQuery(this).url().attr('hash');
	var o = jQuery.extend({
		send: {
			hash: linkHash, //set to false in order not to send the hash to the server
			origin: location.href //same for current location
		},
		ajaxCallback: function(data) {console.log('data received')},
		requestType: 'json' //formatul datelor primite de la server
	}, options); //defaulturi
	return this.each(function(){
		jQuery(this).attr('title', jQuery(this).attr('title') + ' (ajax)'); //titlu
		var url = jQuery(this).attr('href').replace('#'+linkHash, '');
		jQuery(this).click(function(){
			jQuery.post( url, o.send, o.ajaxCallback, o.requestType );
			return false;
		});
	});
};


// returneaza array asociativ dintr-un string gen "caca=maca&waca=bacca"
jQuery.sliceQuery = function(options) {
	var o = jQuery.extend( {
		query : jQuery(document).url().attr('query')
	// default partea de dupa ? si inainte de # in urlul curent (query string).
	// Mere si 'anchor', de ex.
			}, options);
	o.query = o.query.replace('?', '');
	var Params = new Object();
	if (!o.query)
		return Params; // return empty object
	var Pairs = o.query.split(/[;&]/);
	for ( var i = 0; i < Pairs.length; i++) {
		var KeyVal = Pairs[i].split('=');
		if (!KeyVal || (KeyVal.length != 2 && KeyVal.length != 1))
			continue;
		var key = unescape(KeyVal[0]);
		var val = unescape(KeyVal[1]);
		if (!val)
			val = null;
		val = val.replace(/\+/g, ' ');
		Params[key] = val;
	}
	return Params;
};